package com.anan;

import com.anan.bean.TableInfo;
import com.anan.builder.*;
import com.anan.utils.PropertiesUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class AnanJavaApplication {
    private static final Logger logger = LoggerFactory.getLogger(AnanJavaApplication.class);

    public static void main(String[] args) {

        String projectName = "server";  // 项目名字
        String dataBaseName = "onlyoffice";  // 数据库名字

        String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());

        logger.info("开始编辑代码......");
        try {

            BuildMapper.createBaseMapper(projectName);
            BuildService.createBaseService(projectName);
            BuildException.create(projectName);
            BuildUtils.create(projectName);
            BuildResources.create(projectName,dataBaseName);
            BuildAnnotation.create(projectName);
            BuildAspect.create(projectName);
            BuildConfig.create(projectName);


            List<TableInfo> tableInfoList = GetTableInfo.getTables(dataBaseName);
            for (TableInfo tableInfo : tableInfoList) {
                //构建bean
                BuildController.create(tableInfo,projectName);
                BuildEntity.create(tableInfo, projectName);
                BuildMapper.createMapper(tableInfo, projectName);
                BuildService.create(tableInfo, projectName);
            }
            logger.info("代码编辑成功!");
        } catch (Exception e) {
            logger.error("生成代码失败，错误信息:", e);
        }
    }
}
